package com.gem.day04.exercise;

/**
 * 输入两个正整数m和n，求其最大公约数和最小公倍数
 */
public class Exercise3 {
	public static void main(String[] args) {
		print(9, 4);
	}

	/**
	 * 打印两个数的最大公约数和最小公倍数
	 */
	public static void print(int m, int n) {
		int yshu = 1;
		int bshu = m * n;
		int temp = 1;
		if (n < m) {
			temp = n;
			n = m;
			m = temp;
		}
		while (m != 0) {
			temp = n % m;
			n = m;
			m = temp;
		}
		yshu = n;
		bshu /= n;
		System.out.println("最大公约数: " + yshu);
		System.out.println("最小公倍数: " + bshu);
	}
}
